




/*
*************************************************************************
本文件归属于西安协同时光软件有限公司，未经许可，不得擅自使用、拷贝和修改
*项目组:金堆城钼业股份有限公司科研项目管理信息系统项目组
*版 本: 1.0   
*日 期：04/25/2010    
*作 者： Administrator   
*************************************************************************   
*/  
package com.application.projectTeams.struts.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.application.projectTeams.commons.Constants;
import com.application.projectTeams.entity.Projectteams;
import com.application.projectTeams.service.ProjectteamsService;
import com.application.projectTeams.struts.form.ProjectteamsForm;
import com.manager.BaseAction;
import com.manager.commons.RandomKey;
import com.manager.commons.page.PageBean;
 /**
 * 
 * Copyrights 1997-2008 西安协同时光软件有限公司<br />
 * 
 * 
 * Description:ProjectteamsAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: Code Generator <br />
 * 
 * History: <br />
 * 
 * 04/25/2010 SyncBase Code Generator initial version.
 * 
 */
public class ProjectteamsAction extends BaseAction
{
       
       /**
	 * Service层实例
	 */
	private ProjectteamsService projectteamsService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
        private Projectteams projectteams;


        /**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	

        /**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddProjectteams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toAddProjectteamss");
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addProjectteams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addProjectteamss");
		Projectteams projectteams = this.getProjectteams(form);
        projectteams.setId(RandomKey.generateID_String_19());
        projectteams.setInputtime(new Date());
//        projectteams.setInputby(this.getCurrUserInfo(request).getUserId() + "");
		this.projectteamsService.insertObject(projectteams);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteProjectteams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("deleteProjectteamss");
		ProjectteamsForm projectteamsForm = (ProjectteamsForm) form;
		this.projectteamsService.deleteProjectteamss(projectteamsForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateProjectteams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toUpdateProjectteamss");

		Projectteams projectteams = this.getProjectteams(form);
		projectteams = this.projectteamsService.getUpdateProjectteams(projectteams.getId());
		request.setAttribute(Constants.PROJECTTEAMS, projectteams);
		return mapping.findForward(Constants.SUCCESS);
	}

        
	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateProjectteams(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("updateProjectteamss");
		Projectteams projectteams = this.getProjectteams(form);
        projectteams.setAmendtime(new Date());
//        projectteams.setAmendby(this.getCurrUserInfo(request).getUserId() + "");
		this.projectteamsService.updateObject(projectteams);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewProjectteams(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("viewProjectteams");

		Projectteams projectteams = this.getProjectteams(form);
		projectteams = this.projectteamsService.getUpdateProjectteams(projectteams.getId());
		request.setAttribute(Constants.PROJECTTEAMS, projectteams);
		return mapping.findForward(Constants.SUCCESS);
	}

	// get--set
	/**
	 * @return the ProjectteamsService
	 */
	public ProjectteamsService getProjectteamsService() {
		return this.projectteamsService;
	}

	/**
	 * @param ProjectteamsService
	 *  the ProjectteamsService to set
	 */
	public void setProjectteamsService(ProjectteamsService projectteamsService) {
		this.projectteamsService = projectteamsService;
	}

	/**
	 * 获取Projectteams实体
	 * @param ActionForm
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 * @return the Projectteams
	 */
	public Projectteams getProjectteams(ActionForm form) throws IllegalAccessException, InvocationTargetException {
		ProjectteamsForm projectteamsForm = (ProjectteamsForm) form;
		projectteams = new Projectteams();
		BeanUtils.copyProperties(projectteams, projectteamsForm);
		return projectteams;
	}
    
        public void setProjectteams(Projectteams projectteams) {
		this.projectteams = projectteams;
	}

}
